<template>
  <el-card class="box-card">
    <div class="title" style="color: #333333; font-size: 20px; font-weight: bold">
      条件筛选
    </div>
    <el-form label-position="right" label-width="100px" size="mini" :inline="true" :model="ss" ref="refform"
      class="demo-form-inline wrap_inline">
      <el-form-item label="补贴规则名称">
        <el-input v-model="ss.name" placeholder clearable class="input_inner"></el-input>
      </el-form-item>
      <el-form-item label="补贴规则编码">
        <el-select v-model="ss.serviceType" clearable class="input_inner">
          <el-option v-for="item in serviceTypes" :key="item.value" :label="item.name" :value="item.value"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="制定时间">
        <el-date-picker v-model="value1" type="date" placeholder="选择日期">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="补贴生效时间">
        <el-date-picker v-model="value1" type="daterange" range-separator="至" start-placeholder="开始日期"
          end-placeholder="结束日期">
        </el-date-picker>
      </el-form-item>

      <el-form-item label="状态">
        <el-cascader class="input_inner" v-model="regionId" :options="regTree" :props="defaultProps" clearable
          @change="handleChange"></el-cascader>
      </el-form-item>
      <el-form-item>
        <el-button style="margin-left: 20px" type="primary" @click="cx">查询</el-button>
        <el-button @click="reset" type="primary">重置</el-button>
      </el-form-item>
    </el-form>
  </el-card>
</template>
<script>
import { mapState, mapMutations } from "vuex";
export default {
  data() {
    return {
      serviceTypes: [],
      orgTypes: [],
      regionId: [],
      ss: {
        name: null,
        type: null,
        serviceType: null,
        regionId: null,
        linkName: null,
        linkPhone: null
      },
      defaultProps: {
        checkStrictly: true,
        children: "children",
        value: "id",
        label: "name"
      }
    };
  },
  created() { },
  computed: {
    ...mapState(["regTree"])
  },
  methods: {
    setData() {
      this.serviceTypes = this.$parent.$parent.$parent.serviceTypes;
      this.orgTypes = this.$parent.$parent.$parent.orgTypes;
    },
    //省市区三联框点击后触发
    handleChange(value) {
      this.ss.regionId = value[value.length - 1]; //取地区里最后一个值发给后端
    },
    cx() {
      this.$parent.$parent.$parent.$refs.biaoge.cx(this.ss);
      this.$parent.$parent.$parent.$refs.biaoge.ids = null;
      this.$parent.$parent.$parent.$refs.tree.selOrg = null;
    },
    reset() {
      this.ss = {};
      this.regionId = [];
      this.$parent.$parent.$parent.$refs.biaoge.ids = null;
      this.$parent.$parent.$parent.$refs.tree.selOrg = null;
    },
    getTreeData(data) {
      for (var i = 0; i < data.length; i++) {
        if (data[i].children.length < 1) {
          data[i].children = undefined;
        } else {
          this.getTreeData(data[i].children);
        }
      }
      return data;
    }
  }
};
</script>


<style lang="scss" scoped>
.wrap_inline {
  padding: 14px 5px 0px 5px;

  .el-form-item {
    margin-bottom: 12px;
  }
}

.wrap_inline .input_inner {
  width: 120px;
}
</style>